package com.ruoyi.web.controller.WMS;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.HUAWEI.TBtpMtlCurriculumViateTiDTO;
import com.ruoyi.system.domain.Pull.MaterialPlug;
import com.ruoyi.system.domain.WMS.MaterialFeedbackDTO;
import com.ruoyi.system.domain.WMS.RefuelingOrderDTO;
import com.ruoyi.system.domain.WMS.RptInPackageDTO;
import com.ruoyi.system.service.WMSService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @description:
 * @author: zhengxiong.jiang
 * @createDate: 2023/3/3
 * @version: 1.0
 */
@Api(tags = "wms调用接口api")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/wms" )
public class WMSController {

    @Autowired
    private WMSService wmsService;

    @PostMapping("/materialFeedback")
    @ApiOperation(value = "补料（领料）接口反馈")
    public AjaxResult materialFeedback(@RequestBody List<TBtpMtlCurriculumViateTiDTO> dto) {
        return AjaxResult.success(wmsService.materialFeedback(dto));
    }

    @PostMapping("/materialIssued/{ids}")
    @ApiOperation(value = "物料下发至WMS")
    public AjaxResult materialIssued(@PathVariable("ids")String ids) {
        List<Long> collect = Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList());
        return AjaxResult.success(wmsService.materialIssued(collect));
    }

    @PostMapping("/lock")
    @ApiOperation(value = "锁定/解锁")
    public AjaxResult lock(@RequestBody List<Integer> pkids) {
        return AjaxResult.success(wmsService.lock(pkids));
    }

    @GetMapping("/gldSync")
    @ApiOperation(value = "华为隔离单数据同步")
    public AjaxResult gldSync() {
        wmsService.gldSync();
        return AjaxResult.success();
    }

    @PostMapping("/sedPackage")
    @ApiOperation(value = "包装信息下发MOM->WMS")
    public AjaxResult sedPackage(@RequestBody List<RptInPackageDTO> dto) {

        return AjaxResult.success(wmsService.sedPackage(dto));
    }

}
